﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace InstantMessaging
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        //FontFamily fontFamily = new FontFamily("#FontAwesome");
        //FontFamily fontFamily = new FontFamily("resource/#FontAwesome");
        //FontFamily fontFamily = new FontFamily("./#FontAwesome");
        //FontFamily fontFamily = new FontFamily("Resources\\#FontAwesome");
        //FontFamily fontFamily = new FontFamily(@"Resource\\#FontAwesome");
        //FontFamily fontFamily = new FontFamily("pack://application:,,,/#FontAwesome");
        //FontFamily fontFamily = new FontFamily(new Uri("pack://application:,,,/InstantMessaging"), "component/Resources/#FontAwesome");
        //FontFamily fontFamily = new FontFamily(new Uri("pack://application:,,,/InstantMessaging"), "component/Resources/#FontAwesome");
        //FontFamily fontFamily = new FontFamily(new Uri("pack://application:,,,/InstantMessaging/component/Resources"), "#FontAwesome");
        FontFamily fontFamily = new FontFamily(@"fontawesome-webfont.ttf");
        private System.Windows.Forms.NotifyIcon notifyIcon;

        public MainWindow()
        {
            InitializeComponent();
            //this.Ini();
        }

        private void Ini()
        {
            this.notifyIcon = new System.Windows.Forms.NotifyIcon
            {
                Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath),
                Visible = true
            };
            //System.Windows.Application.Current.Shutdown();

            this.SizeChanged += MainWindow_SizeChanged;//窗口大小改变事件，隐藏时启用托盘
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.WindowStyle = WindowStyle.None;
            this.AllowsTransparency = true;
            this.Background = Brushes.Gray;
            //object obj = this.TryFindResource("#FontAwesome");
            //Uri uri = new Uri("pack://application:,,,InstantMessaging");
            this.Content = this.GetGrid_Banner();
        }

        private void MainWindow_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            
        }

        private Grid GetGrid_Banner()
        {
            Grid grid = new Grid();
            Label label_ico = new Label();
            label_ico.FontFamily = fontFamily;
            label_ico.Content = "\xf000";
            label_ico.FontSize = 50;
            grid.Children.Add(label_ico);
            Label label_ico2 = new Label();
            label_ico2.FontFamily = fontFamily;
            label_ico2.Content = "\uf000";
            label_ico2.FontSize = 50;
            label_ico2.Margin = new Thickness(100, 0, 0, 0);
            grid.Children.Add(label_ico2);
            return grid;
        }

        private void TextBlock_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            Close();
        }

        private void TextBlock_MouseMove(object sender, MouseEventArgs e)
        {
            (sender as TextBlock).Background = Brushes.Coral;
        }

        private void TextBlock_MouseLeave(object sender, MouseEventArgs e)
        {
            (sender as TextBlock).Background = Brushes.Snow;
        }
    }
}
